package com.luhuiguo.gwt.mvp.dispatcher.client;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.luhuiguo.gwt.mvp.dispatcher.shared.exception.SecureException;

/**
 * 
 * @author LuHuiguo
 * @version $Id: SecuredAsyncCallback.java 11 2009-12-26 13:39:17Z luhuiguo $
 * @param <T>
 */
public abstract class SecuredAsyncCallback<T> implements AsyncCallback<T> {

    public final void onFailure(final Throwable caught) {
        if (caught != null && caught instanceof SecureException) {
            onSecurityException((SecureException) caught);
        } else {
            onException(caught);
        }
    }

    protected abstract void onSecurityException(final SecureException caught);

    protected abstract void onException(final Throwable caught);

}
